﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ATest.Bll.Repositories;
using ATest.Bll;

namespace ATest.Tests.MockObjects
{
    public class MockQuestionRepository : Moq.Mock<IQuestionRepository>
    {
        public MockQuestionRepository()
        {
        }

        public MockQuestionRepository(IEnumerable<Question> questions)
        {
            SetupQuestions(questions.ToList());
        }

        public void SetupQuestions(List<Question> questions)
        {
            //set up getbyid
            questions.ForEach(question => Setup(x => x.GetById(question.Id)).Returns(question));
            //setup getbytestid
            questions.GroupBy(x => x.TestId).ToList().ForEach(questionList => Setup(x => x.GetAllByTestId(questionList.Key)).Returns(questionList.AsQueryable()));
        }
    }
}
